#!/bin/sh
MYENV=`grep oracle /etc/passwd|awk -F: '{print $6}'`
for loop in $MYENV
do 
cd $loop
.  .profile 
echo $ORACLE_SID
sqlplus monitor/monitor@$ORACLE_SID << EOF  >/dev/null
#sqlplus /nolog << EOF
@/home/monitor/checkT.sql
exit
EOF
cat /home/monitor/tablespace.txt|grep -v rows|awk 'BEGIN {print "TABLESPACE_NAME     MAX_SPACE SUM_BLOCKS USED_SPACE USED_RATE(%) FREE_SPACE(M)\n------------------ ---------- ---------- ---------- ------------ -------------"} {if ( $5> 80 || $6<300 ) print $0}'
rm /home/monitor/tablespace.txt
done
exit 0
